home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / Buch / Wexl3.cpp < prev    next >
C/C++ Source or Header  |  1999-01-26  |  2KB  |  71 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "Wexl3.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8.  
  9. //---------------------------------------------------------------------------
  10.  
  11. template <class AllTyp>
  12. void ExChange (AllTyp *x, AllTyp *y)
  13. {
  14.   AllTyp z = *x; *x = *y; *y = z;
  15. }
  16.  
  17. template <class AllTyp>
  18. void ShowIt (AllTyp x, AllTyp y)
  19. {
  20.   Form1->Panel1->Caption = AllTyp (x);
  21.   Form1->Panel2->Caption = AllTyp (y);
  22. }
  23.  
  24. //---------------------------------------------------------------------------
  25.  
  26. String Text1, Text2;
  27. double Zahl1, Zahl2;
  28. bool Modus;
  29. TForm1 *Form1;
  30.  
  31. //---------------------------------------------------------------------------
  32. __fastcall TForm1::TForm1(TComponent* Owner)
  33.     : TForm(Owner)
  34. {
  35. }
  36. //---------------------------------------------------------------------------
  37. void __fastcall TForm1::Button1Click(TObject *Sender)
  38. {
  39.   Text1 = InputBox
  40.     ("1. String","BestΣtigen oder NEU","Hallo");
  41.   Text2 = InputBox
  42.     ("2. String","BestΣtigen oder NEU","Hoppla");
  43.   ShowIt (Text1, Text2);
  44.   Modus = true;
  45. }
  46. //---------------------------------------------------------------------------
  47. void __fastcall TForm1::Button2Click(TObject *Sender)
  48. {
  49.   Zahl1 = StrToFloat (InputBox
  50.     ("1. Zahl","BestΣtigen oder NEU","0"));
  51.   Zahl2 = StrToFloat (InputBox
  52.     ("2. Zahl","BestΣtigen oder NEU","1"));
  53.   ShowIt (Zahl1, Zahl2);
  54.   Modus = false;
  55. }
  56. //---------------------------------------------------------------------------
  57. void __fastcall TForm1::Button3Click(TObject *Sender)
  58. {
  59.   if (Modus)
  60.   {
  61.     ExChange (&Text1, &Text2);
  62.     ShowIt (Text1, Text2);
  63.   }
  64.   else
  65.   {
  66.     ExChange (&Zahl1, &Zahl2);
  67.     ShowIt (Zahl1, Zahl2);
  68.   }
  69. }
  70. //---------------------------------------------------------------------------
  71.